<template>
  <div class="pic">
    <img :src="arr.dogImgUrl" alt="" />
    <p @click="change(arr.dogName)" :style="{ backgroundColor: allColor }">
      {{ arr.dogName }}
    </p>
  </div>
</template>

<script>
export default {
  props: ["arr"],
  data() {
    return {
      allColor: "",
    };
  },
  methods: {
    change(dogName) {
      this.allColor = `rgb(${Math.floor(Math.random() * 256)},${Math.floor(
        Math.random() * 256
      )},${Math.floor(Math.random() * 256)})`;
      this.$emit("changelove", dogName);
    },
  },
};
</script>

<style scoped>
.pic {
  height: 250px;
  width: 300px;
  border: 2px solid #000;
  text-align: center;
  float: left;
}
img {
  height: 200px;
  width: 100%;
}
p {
  width: 300px;
}
</style>